var monitoringData,
listTpl = enco.util.createTemplate(
	'<tr>' +
	'<td>{seq}</td>' +
	'<td>{regYmdt}</td>' +
	'<td>{wrtrMbrId}</td>' +
	'<td class="left"><textarea style="border:0px;width:410px; overflow-y:auto;" rows="4" readonly>{cont}</textarea></td>' +
	'<td>{bbsTypeNm}</td>' +
	'<td>{trtStatNm}</td>' +
	'<td>{trtrEmpNm}<br>{trtYmdt}</td>' +
	'<td><a href="javascript:;" onclick="doDetail(\'{commCd}\',\'{commCdCatCd}\');"><img src="/share/img/btn_view_more.jpg"></a></td>' + 
	'</tr>',
	'<tbody>'
),
noListTpl = enco.util.createTemplate(
	'<tr>' +
	'<td colspan="8">검색된 데이터가 없습니다.</td>' +
	'</tr>',
	'<tbody>'
);

$(document).ready(function(){
	$("#loading").ajaxStart(function(){
	    $.blockUI({ 
	        message: $(this), 
	        css: { 
	            top:  ($(window).height() - 100) /2 + 'px', 
	            left: ($(window).width() - 400) /2 + 'px', 
	            width: '400px' 
	        } 
	    });
	}).ajaxComplete(function(){
		 setTimeout($.unblockUI, 100);
	});
	
	//calendar
	$('.date-pick').datePicker({autoFocusNextInput: true});
	$(".date-pick").mask("9999-99-99");	//Date type masking
	//checkbox
	$(".chk").checkSelect("chkAll",false);
	$(".chkAll").checkAll("chk",false);
});

function doSearch(page) 
{
	var params = {
		page: (page == undefined) ? 1 : page,
		startDate: $("#startDate").val(),
		endDate: $("#endDate").val(),
		productNo: '',
		bbsTypeCd: $("#bbsTypeCd").val(),
		wrtrMbrId: $("#wrtrMbrId").val(),
	};
	
	$.get("/bbs/deletedMonitoring/search", params, function(result){
		monitoringData = JSON.parse(result).monitoringList;
		var len = monitoringData.length;
		var total = JSON.parse(result).total;
		var target = document.getElementById("monitoringList");
		
		if(len > 0) {
			for(var i=0;i<len;++i) {
				listTpl.append(null, monitoringData[i]);
			}
			listTpl.flush(target, "overwrite");
		} else {
			noListTpl.overwrite(target, null);
		}
		
		$("#total").text(total);
		
		enco.util.paginate(JSON.parse(result).paginate)
				.flush(document.getElementById("paginate"));
	});
	
	return false;
}